package provider;

import anaydis.sort.Sorter;
import anaydis.sort.SorterType;
import anaydis.sort.provider.SorterProvider;
import impl.*;

import java.util.EnumMap;
import java.util.Map;

public class SorterProviderImpl implements SorterProvider {

    private Map<SorterType, Sorter> map;

    public SorterProviderImpl() {
        map = new EnumMap<SorterType, Sorter>(SorterType.class);
        map.put(SorterType.BUBBLE, new BubbleSorter());
        map.put(SorterType.INSERTION, new InsertionSorter());
        map.put(SorterType.SELECTION, new SelectionSorter());
        map.put(SorterType.QUICK, new QuickSorter());
        map.put(SorterType.H, new HSorter());
        int[] secuencia = {1, 4, 13, 40, 121, 364, 1093, 3280, 9841};
        map.put(SorterType.SHELL, new ShellSorter(secuencia));
        map.put(SorterType.QUICK_CUT, new QuickSorterCutOff(10));
        map.put(SorterType.QUICK_NON_RECURSIVE, new QuickSorterNonRecursive());
        map.put(SorterType.QUICK_MED_OF_THREE, new QuickSorterMedianOfThree());
        map.put(SorterType.QUICK_THREE_PARTITION, new QuickSorterThreeWay());
        map.put(SorterType.MERGE_BOTTOM_UP, new MergeSorterBottomUp());
        map.put(SorterType.MERGE, new MergeSorterTopDown());

    }

    public Sorter getSorterForType(SorterType sorterType) {
        return map.get(sorterType);
    }

    public Iterable<Sorter> getAllSorters() {
        return map.values();
    }
}

